#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(I,B,E)  for(int I=B;I<(E);++I)
#define loop(I,B,E) for(int I=B;I<=(E);++I)
template<class T>void cmax (T& _,T __){if(_<__) _=__;}
template<class T>void cmin (T& _,T __){if(_>__) _=__;}
const int maxn=1e5+10,INF=0x3f3f3f3f;
const LL LINF=(LL)INF<<32|INF,mod=998244353;
typedef LL val_t;
const int MS=10;//Matrix Size
struct Matrix{
	val_t a[MS][MS];
	Matrix(){memset(a,0,sizeof(a));}
	val_t* operator [] (const int p){return a[p];}
	void clear(){memset(a,0,sizeof(a));}
	static Matrix eye(){
		Matrix ret;
		rep(i,0,MS) ret[i][i]=1;
		return ret;
	}
	Matrix operator * (Matrix& T){
		Matrix ret;
		rep(i,0,MS) rep(k,0,MS) rep(j,0,MS)
			ret[i][j]=(ret[i][j]+a[i][k]*T[k][j])%mod;
		return ret;
	}
};
struct SegmentTree
{
	#define left (p<<1)
	#define right (p<<1|1)
	Matrix prod[maxn<<2];
	void build(int p,int L,int R,Matrix& m)
	{
		if(L==R)
		{
			if(L==1) prod[p]=Matrix::eye();
			else prod[p]=m;
			return;
		}
		int mid=(L+R)>>1;
		build(left,L,mid,m);
		build(right,mid+1,R,m);
		prod[p]=prod[right]*prod[left];
		return;
	}
	void change(int p,int L,int R,int pos,Matrix& m)
	{
		if(L==R)
		{
			prod[p]=m;
			return;
		}
		int mid=(L+R)>>1;
		if(pos<=mid) change(left,L,mid,pos,m);
		else change(right,mid+1,R,pos,m);
		prod[p]=prod[right]*prod[left];
		return;
	}
	LL query(){
		LL ans=0;
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				ans+=prod[1][i][j];
			}
		}
		return ans%mod;
	}
}dp;
int main()
{
	int T,N,M,K,p,a,cnt=0;
	scanf("%d",&T);
	while(T--){
		scanf("%d%d%d",&N,&M,&K);
		Matrix trans;
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				trans[i][j]=abs(i-j)<=K?1:0;
			}
		}
		dp.build(1,1,N,trans);
		printf("%lld ",dp.query());
		for(int i=1;i<=M;i++)
		{
			scanf("%d%d",&p,&a);
			trans.clear();
			if(p==1) trans[a][a]=1,cnt++;
			else for(int j=0;j<10;j++)
				trans[a][j]=abs(a-j)<=K?1:0;
			dp.change(1,1,N,p,trans);
			printf("%lld%c",dp.query(),i==M?'\n':' ');
		}
	}
	return 0;
}
